  <?php

use Illuminate\Support\Str;

function route_class()
{
    return str_replace('.', '-', Route::currentRouteName());
}

function isMobile()
{
    if(Agent::isMobile()) {
        return "mobile.";
    } else {
        return "pc.";
    }
}

function finance_format($val=0)
{
    return $val / 1000;
}

function get_exchange_rate () {
    $val = \DB::table('systems')->where('id', 1)->get();

    return $val[0]->exchange_rate;
}

function thToRmb($val)
{
    return number_format(finance_format($val) / get_exchange_rate (), 2);
}

function GetRandStr($len)
{
    $a = range('a','z');

    $b = range('A','Z');

    $c = range('0','9');

    $chars = array_merge($a,$b,$c);

    $charslen = count($chars)-1;

    shuffle($chars);

    $output = '';

    for($i=0;$i<$len;$i++){

        $output.=$chars[mt_rand(0,$charslen)];
    }

    return $output;
}

function user_history($val)
{
    return '*'.substr($val, 6, 4);
}


function show_user_num($val)
{
    $a = substr($val, 0, 3);
    $b = substr($val, 3, 3);
    $c = substr($val, 6, 4);

    return $a.' '.$b.' '.$c;
}
